package com.liuweiheng.cloudproviderpayment8002;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.*;
import java.util.stream.IntStream;

/**
 * Stream流的使用
 *
 * @author lwh
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class Stream {

    @Test
    public void func() {
        // Collection对象的stream方法
        List<String> list = new ArrayList<>();
        list.add("apple");
        list.add("huawei");
        list.add("xiaomi");

        list.forEach(System.out::println);

        // Arrays工具类的stream方法
        int[] arr = new int[]{1, 2, 3, 4};
        IntStream stream = Arrays.stream(arr);
        stream.forEach(System.out::println);

    }

}
